<?php
require_once ROOT_LIBRARY_UTILITY.DS. 'BaseController.php';
require_once ROOT_LIBRARY_UTILITY.DS. 'Globals.php';

require_once ROOT_APPLICATION_MODULE_BACKEND_MODELS.DS. 'Model_Project.php';
require_once ROOT_APPLICATION_MODULE_BACKEND_MODELS.DS. 'Model_Service_Type.php';
require_once ROOT_APPLICATION_MODULE_BACKEND_MODELS.DS. 'Model_Customer.php';

class ProjectController extends BaseController{

	public function init(){
		parent::init();

	}

	public function indexAction(){
        try
        {
           $type = $this->_request->getParam("type");
            if($this->_request->getMethod() == "POST")
            {
                
            }
            else
            {
                $mdProject = new Model_Project();
                $this->view->listProjects = $mdProject->getByServiceType($type);
                
                $mdServiceType = new Model_Service_Type();
                $this->view->serviceType = $mdServiceType->_getByKey($type);
                $this->view->serviceTypeList = $mdServiceType->_getAll();
                
                $this->view->serviceTypeId = $type;
            }
        }
        catch(Exception $ex)
        {
            
        }
	}
    
    public function detailAction()
    {
        try
        {
            $projectId = $this->_request->getParam('id');
            
            $mdProject = new Model_Project();
            $project = $mdProject->_getByKey($projectId);
            $this->view->project = $project;
            
            $mdServiceType = new Model_Service_Type();
            $this->view->serviceType = $mdServiceType->_getByKey($project->service_types_id);
            $this->view->serviceTypeList = $mdServiceType->_getAll();
            
            $mdCustomer = new Model_Customer();
            $this->view->customer = $mdCustomer->_getByKey($project->customers_id);
        }
        catch(Exception $ex)
        {
            
        }
    }
}